package com.yoj.model.enums;

import org.apache.commons.lang3.ObjectUtils;

/**
 * 代码沙箱类型枚举类
 */
public enum CodeSandboxEnum {

    EXAMPLE("example", "示例代码沙箱"),
    REMOTE("remote", "远程代码沙箱"),
    THIRD_PARTY("thirdParty", "第三方代码沙箱");

    private final String value;

    private final String name;

    CodeSandboxEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    /**
     * 根据 value 获取枚举
     */
    public static CodeSandboxEnum getEnumByValue(String value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (CodeSandboxEnum anEnum : CodeSandboxEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }

    public String getValue() {
        return value;
    }

    public String getName() {
        return name;
    }
}
